import type { ApiPagination, ApiPaginationParams } from '#types/utils'
import { requestClient } from '../request'
import type { sellerItemForm, sellerPageListItem } from './model/sellerModel'

// 卖家管理
export default class CustomerSellerApi {
    static get inst() {
        return CustomerSellerApi._inst || (CustomerSellerApi._inst = new CustomerSellerApi())
    }
    private static _inst: CustomerSellerApi
    add(params: Partial<sellerItemForm>) {
        return requestClient.post<null>('/buser/add', params)
    }
    approval(data: { approvalMessage?: string; approvalStatus: number; ids: number[] }) {
        return requestClient.put<boolean>('/orders/approval', data)
    }
    delete(ids: Array<number | string>) {
        return requestClient.delete<null>(`/buser/delete/${ids}`)
    }
    details(id: number) {
        return requestClient.get<sellerPageListItem>(`/buser/${id}`)
    }

    edit(id: number | string, params: Partial<sellerItemForm>) {
        return requestClient.put<null>(`/buser/edit/${id}`, params)
    }
    /**
     * 站点管理分页
     * @param params
     */
    getPageList(params: ApiPaginationParams<{ username?: string }>) {
        return requestClient.get<ApiPagination<sellerPageListItem>>('/buser/index', {
            params
        })
    }
    statuseEdit(params: Partial<sellerItemForm>) {
        return requestClient.put<null>(`/buser/edit/status/`, params)
    }
}
